<template>
  <div class="tabs-item-wrapper">
    <div class="sta-data">
      <div class="item">
        <div class="title">今日申领场所码</div>
        <div class="total">累计申领 16,758,009 个</div>
        <div class="today">
          <div class="val">214,398<span> 个</span></div>
          <div class="increase">较昨日 <span class="up"><i class="el-icon-caret-top"></i>2.30%</span></div>
        </div>
      </div>
      <div class="item">
        <div class="title">今日申领场所码</div>
        <div class="total">累计申领 16,758,009 个</div>
        <div class="today">
          <div class="val">214,398<span> 个</span></div>
          <div class="increase">较昨日 <span class="up"><i class="el-icon-caret-top"></i>2.30%</span></div>
        </div>
      </div>
    </div>
    <div class="sta-chart">
      <div class="title">场所扫码统计</div>
      <div id="trendChart"></div>
    </div>
  </div>
</template>

<script>
import { Area } from "@antv/g2plot";
export default {
  name: 'CsmStatistics',
  data() {
    return {
      //场所码趋势统计
      trendChart: [
        { name: "扫码次数", date: "4-12", value: 12632, },
        { name: "扫码次数", date: "4-13", value: 8454 },
        { name: "扫码次数", date: "4-14", value: 30393 },
        { name: "扫码次数", date: "4-15", value: 28731 },
        { name: "扫码次数", date: "4-16", value: 3612 },
        { name: "扫码次数", date: "4-17", value: 47212 },
        { name: "扫码次数", date: "4-18", value: 16872 },
        { name: "扫码次数", date: "4-19", value: 18272 },
        { name: "扫码次数", date: "4-20", value: 18732 },
        { name: "扫码次数", date: "4-21", value: 17622 },
        { name: "扫码次数", date: "4-22", value: 11283 },
        { name: "扫码次数", date: "4-23", value: 19012 },
        { name: "扫码次数", date: "4-24", value: 25823 },
        { name: "扫码次数", date: "4-25", value: 21001 },
        { name: "扫码次数", date: "4-26", value: 17653 }
      ],
    }
  },
  mounted(){
    this.initTrendChart();
  },
  methods:{
    initTrendChart: function (){
      let _this = this;
      let data = _this.trendChart;
      const area = new Area("trendChart", {
        data,
        xField: "date",
        yField: "value",
        seriesField: "name",
        meta: {
          value: {
            formatter: (v) => `${v} 个`,
          },
        },
        areaStyle: (type) => {
        return {
            fill: type.name == "活跃场所码" ?
            "l(270) 0:#ffffff 0.5:#7ec2f3 1:#1890ff":
            "l(270) 0:#ffffff 0.5:#a0d8cb 1:#5cdebf",
          };
        },
      });
      area.render();
    },
  }
}
</script>
<style lang="scss" scoped>

.tabs-item-wrapper{
  // background-color: rgba(242, 242, 242, 1);
}

.sta-data{
  display: flex;
  display: -webkit-flex;
  padding: 40px 0 0 20px;
  .item{
    flex: 1;
    background-color: #f1f2f6;
    border-radius: 5px;
    // box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1);
    padding: 20px;
    margin-right: 15px;
    
    .title{
      font-weight: bold;
    }

    .total{
      color: #979fb9;
      margin-top: 7px;
    }

    .today{
      margin-top: 15px;
      display: flex;
      align-items: center;
      .val{
        flex: 6;
        font-size: 2rem;
        font-weight: bold;

        span{
          font-size: 0.9rem;
          font-weight: normal;
        }
      }

      .increase{
        flex: 4;
        color: #979fb9;
        font-size: 0.8rem;
        text-align: right;
        .up{
          color: #44d196;
        }

        .down{
          color: #d14444;
        }
      }
    }
  }
}

.sta-chart{
  padding: 50px;
  .title{
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 600;
  }
}
</style>